﻿<navigation:Page x:Class="PmuRegistry.Silverlight.Pages.Devices.InputWizard" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
           xmlns:layoutToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"            
           xmlns:converter="clr-namespace:PmuRegistry.Silverlight.Converters"           
           Title="NASPI PMU Registry: Device Configuration Wizard">
    <Grid x:Name="GridConfigurationWizard">
        <Border Style="{StaticResource PortletBorderStyle}">
            <StackPanel Orientation="Vertical">
                <TextBlock Text="Device Configuration Wizard" Foreground="#FFFFFFFF" HorizontalAlignment="Center" FontSize="{StaticResource LargerTextSize}" Padding="5" />
                <Border Style="{StaticResource HeaderRowBorderStyle}">
                    <layoutToolkit:Accordion x:Name="AccordianWizard" HorizontalAlignment="Center" Style="{StaticResource AccordionStyle}" 
                                            SelectionMode="One" ItemContainerStyle="{StaticResource AccordionItemStyle}" AccordionButtonStyle="{StaticResource AccordionButtonStyle}">
                        <layoutToolkit:AccordionItem Header="Step 1: Upload Configuration">
                            <layoutToolkit:AccordionItem.Content>
                                <Grid HorizontalAlignment="Center" Width="{StaticResource ApplicationMinWidth}" Height="{StaticResource XXXLargeItemSize}" Margin="5">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="3*" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>

                                    <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Text="Select XML Configuration File (from PMU Connection Tester)" HorizontalAlignment="Left" Margin="2"/>
                                    <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
                                        <TextBox x:Name="TextBoxConfigurationFile" Width="{StaticResource XXLargeItemSize}" Height="{StaticResource XXXSmallItemSize}" HorizontalAlignment="Left" TextAlignment="Left" VerticalAlignment="Center" Margin="2"/>
                                        <Button x:Name="ButtonBrowseConfigurationFile" Content="../../Images/Browse.png" Tag="Browse" Template="{StaticResource ImageButtonTemplate}" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="2" Cursor="Hand">
                                            <Button.RenderTransform>
                                                <ScaleTransform x:Name="ButtonBrowseConfigurationFileTransform" ScaleX="1" ScaleY="1" />
                                            </Button.RenderTransform>
                                        </Button>
                                    </StackPanel>
                                    <TextBlock Grid.Row="4" Grid.Column="0" Text="Device Protocol" HorizontalAlignment="Left" Margin="2"/>
                                    <ComboBox x:Name="ComboboxProtocol" Grid.Row="4" Grid.Column="1" Width="{StaticResource LargerItemSize}" DisplayMemberPath="Value" HorizontalAlignment="Left" Margin="2"/>
                                    <TextBlock Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" x:Name="TextBlockIniFile" Text="Select INI File to Upload" HorizontalAlignment="Left" Margin="2"/>
                                    <StackPanel x:Name="StackPanelIniFile" Orientation="Horizontal" Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="2">
                                        <TextBox x:Name="TextBoxIniFile" Width="{StaticResource XXLargeItemSize}" Height="{StaticResource XXXSmallItemSize}" HorizontalAlignment="Left" TextAlignment="Left" VerticalAlignment="Center" Margin="2"/>
                                        <Button x:Name="ButtonBrowseIniFile" Content="../../Images/Browse.png" Tag="Browse" Template="{StaticResource ImageButtonTemplate}" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="2" Cursor="Hand">
                                            <Button.RenderTransform>
                                                <ScaleTransform x:Name="ButtonBrowseIniFileTransform" ScaleX="1" ScaleY="1" />
                                            </Button.RenderTransform>
                                        </Button>
                                    </StackPanel>
                                    <!--<TextBlock Grid.Row="7" Grid.Column="0" Text="ID Code" HorizontalAlignment="Left" Margin="2"/>-->
                                    <CheckBox x:Name="CheckboxConnectToPDC" Content="Connect to PDC" Grid.Row="7" Grid.Column="1" VerticalAlignment="Center" Margin="2"/>
                                    <TextBlock Grid.Row="8" Grid.Column="0" x:Name="TextBlockPDCName" Text="PDC Name" HorizontalAlignment="Left" Margin="2"/>
                                    <TextBox x:Name="TextBoxPDCName" Grid.Row="8" Grid.Column="1" Width="{StaticResource LargeItemSize}" Height="{StaticResource XXXSmallItemSize}" HorizontalAlignment="Left" TextAlignment="Left" VerticalAlignment="Center" Margin="2"/>
                                    <TextBlock Grid.Row="9" Grid.Column="0" x:Name="TextBlockAcronym" Text="Acronym" HorizontalAlignment="Left" Margin="2"/>
                                    <TextBox x:Name="TextBoxPDCAcronym" Grid.Row="9" Grid.Column="1" Width="{StaticResource SmallItemSize}" Height="{StaticResource XXXSmallItemSize}" HorizontalAlignment="Left" TextAlignment="Left" VerticalAlignment="Center" Margin="2"/>
                                    <TextBlock Grid.Row="10" Grid.Column="0" x:Name="TextBlockPDCDeviceVendor" Text="PDC Device Vendor" HorizontalAlignment="Left" Margin="2"/>
                                    <ComboBox x:Name="ComboboxPDCVendor" Grid.Row="10" Grid.Column="1" Width="{StaticResource LargerItemSize}" DisplayMemberPath="Value" HorizontalAlignment="Left" Margin="2"/>
                                </Grid>
                            </layoutToolkit:AccordionItem.Content>
                        </layoutToolkit:AccordionItem>

                        <layoutToolkit:AccordionItem Header="Step 2: Configure Connection Settings">
                            <layoutToolkit:AccordionItem.Content>
                                <Grid Width="{StaticResource ApplicationMinWidth}" Height="{StaticResource XXXLargeItemSize}" Margin="5" HorizontalAlignment="Center">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="3*" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>

                                    <TextBlock Grid.Row="0" Grid.Column="0" Text="Company" HorizontalAlignment="Left" FontWeight="Bold" Margin="2"/>
                                    <ComboBox x:Name="ComboboxCompany" Grid.Row="0" Grid.Column="1" Width="{StaticResource XLargeItemSize}" DisplayMemberPath="Value" HorizontalAlignment="Left" Margin="2"/>                                    
                                    <TextBlock Grid.Row="2" Grid.Column="0" Text="Interconnection" HorizontalAlignment="Left" FontWeight="Bold" Margin="2"/>
                                    <ComboBox x:Name="ComboboxInterconnection" Grid.Row="2" Grid.Column="1" Width="{StaticResource XLargeItemSize}" DisplayMemberPath="Value" HorizontalAlignment="Left" Margin="2"/>                                    
                                </Grid>
                            </layoutToolkit:AccordionItem.Content>
                        </layoutToolkit:AccordionItem>

                        <layoutToolkit:AccordionItem Header="Step 3: Select Devices to Configure">
                            <layoutToolkit:AccordionItem.Content>
                                <StackPanel Orientation="Vertical" Width="{StaticResource ApplicationMinWidth}" Margin="5">
                                    <Border Style="{StaticResource HeaderRowBorderStyle}">
                                        <StackPanel Orientation="Horizontal">
                                            <Border Style="{StaticResource HeaderRowCellBorderStyle}">
                                                <CheckBox x:Name="CheckAllDevices" Content="" Width="{StaticResource XXSmallItemSize}" IsChecked="True"  HorizontalAlignment="Left" VerticalAlignment="Center" Checked="CheckAllDevices_Checked" Unchecked="CheckAllDevices_Unchecked" />
                                                <!--<TextBlock Text="" Width="{StaticResource XXSmallItemSize}" TextAlignment="Center" FontSize="{StaticResource LargeTextSize}" FontWeight="Bold"/>-->
                                            </Border>
                                            <Border Style="{StaticResource HeaderRowCellBorderStyle}">
                                                <TextBlock Text="Acronym" Width="{StaticResource SmallerItemSize}" TextAlignment="Center" FontSize="{StaticResource LargeTextSize}" FontWeight="Bold"/>
                                            </Border>
                                            <Border Style="{StaticResource HeaderRowCellBorderStyle}">
                                                <TextBlock Text="Name" Width="{StaticResource SmallItemSize}" TextAlignment="Center" FontSize="{StaticResource LargeTextSize}" FontWeight="Bold"/>
                                            </Border>
                                            <Border Style="{StaticResource HeaderRowCellBorderStyle}">
                                                <TextBlock Text="Vendor" Width="{StaticResource SmallerItemSize}" TextAlignment="Center" FontSize="{StaticResource LargeTextSize}" FontWeight="Bold"/>
                                            </Border>
                                            <Border Style="{StaticResource HeaderRowCellBorderStyle}">
                                                <TextBlock Text="Status" Width="{StaticResource SmallerItemSize}" TextAlignment="Center" FontSize="{StaticResource LargeTextSize}" FontWeight="Bold"/>
                                            </Border>
                                            <Border Style="{StaticResource HeaderRowCellBorderStyle}">
                                                <TextBlock Text="Longitude" Width="{StaticResource XSmallItemSize}" TextAlignment="Center" FontSize="{StaticResource LargeTextSize}" FontWeight="Bold"/>
                                            </Border>
                                            <Border Style="{StaticResource HeaderRowCellBorderStyle}">
                                                <TextBlock Text="Latitude" Width="{StaticResource XSmallItemSize}" TextAlignment="Center" FontSize="{StaticResource LargeTextSize}" FontWeight="Bold"/>
                                            </Border>
                                            <Border Style="{StaticResource HeaderRowCellBorderStyle}">
                                                <TextBlock Text="Digitals" Width="{StaticResource XSmallItemSize}" TextAlignment="Center" FontSize="{StaticResource LargeTextSize}" FontWeight="Bold"/>
                                            </Border>
                                            <TextBlock Text="Analogs" Width="{StaticResource XSmallItemSize}" TextAlignment="Center" FontSize="{StaticResource LargeTextSize}" FontWeight="Bold"/>
                                        </StackPanel>
                                    </Border>
                                    <ScrollViewer BorderThickness="0" Padding="0" Height="{StaticResource XXXLargeItemSize}" Width="Auto">
                                        <ItemsControl x:Name="ItemControlDeviceList" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                            <ItemsControl.ItemTemplate>
                                                <DataTemplate>
                                                    <StackPanel Orientation="Vertical">
                                                        <StackPanel Orientation="Horizontal">
                                                            <StackPanel.Resources>
                                                                <converter:StringToDictionaryConverter x:Key="stringToDictionaryConverter" />
                                                            </StackPanel.Resources>
                                                            <Border Style="{StaticResource ContentRowCellBorderStyle}" Width="{StaticResource XXSmallItemSize}">
                                                                <CheckBox HorizontalAlignment="Center" IsChecked="{Binding Path=Include, Mode=TwoWay }" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked"/>
                                                            </Border>
                                                            <Border Style="{StaticResource ContentRowCellBorderStyle}">
                                                                <TextBox Text="{Binding Path=Acronym, Mode=TwoWay}" Width="{StaticResource SmallerItemSize}" TextAlignment="Left" Height="{StaticResource XXXSmallItemSize}" VerticalAlignment="Center"/>
                                                            </Border>
                                                            <Border Style="{StaticResource ContentRowCellBorderStyle}">
                                                                <TextBox Text="{Binding Path=Name, Mode=TwoWay}" Width="{StaticResource SmallItemSize}" TextAlignment="Left" Height="{StaticResource XXXSmallItemSize}" VerticalAlignment="Center" />
                                                            </Border>
                                                            <Border Style="{StaticResource ContentRowCellBorderStyle}">
                                                                <ComboBox x:Name="ComboboxVendor" DisplayMemberPath="Value" SelectedItem="{Binding Path=VendorDeviceID, Mode=TwoWay, Converter={StaticResource stringToDictionaryConverter}}" Width="{StaticResource SmallerItemSize}" Loaded="ComboboxVendor_Loaded" Height="{StaticResource XXXSmallItemSize}" VerticalAlignment="Center"/>
                                                            </Border>
                                                            <Border Style="{StaticResource ContentRowCellBorderStyle}">
                                                                <ComboBox x:Name="ComboboxStatus" DisplayMemberPath="Value" SelectedItem="{Binding Path=StatusID, Mode=TwoWay, Converter={StaticResource stringToDictionaryConverter}}" Width="{StaticResource SmallerItemSize}" Loaded="ComboboxStatus_Loaded" Height="{StaticResource XXXSmallItemSize}" VerticalAlignment="Center"/>
                                                            </Border>
                                                            <Border Style="{StaticResource ContentRowCellBorderStyle}">
                                                                <TextBox Text="{Binding Path=Longitude, Mode=TwoWay}" Width="{StaticResource XSmallItemSize}" TextAlignment="Left" Height="{StaticResource XXXSmallItemSize}" VerticalAlignment="Center"/>
                                                            </Border>
                                                            <Border Style="{StaticResource ContentRowCellBorderStyle}">
                                                                <TextBox Text="{Binding Path=Latitude, Mode=TwoWay}" Width="{StaticResource XSmallItemSize}" TextAlignment="Left" Height="{StaticResource XXXSmallItemSize}" VerticalAlignment="Center"/>
                                                            </Border>
                                                            <Border Style="{StaticResource ContentRowCellBorderStyle}">
                                                                <StackPanel Orientation="Horizontal"  Width="{StaticResource XSmallItemSize}" HorizontalAlignment="Center" VerticalAlignment="Center" >
                                                                    <CheckBox x:Name="CheckboxAddDigitals" IsChecked="{Binding Path=AddDigitals, Mode=TwoWay}" Content="Add"/>
                                                                    <TextBlock Text="["/>
                                                                    <TextBlock Text="{Binding Path=DigitalCount}" />
                                                                    <TextBlock Text="]"/>
                                                                </StackPanel>
                                                            </Border>
                                                            <Border Style="{StaticResource ContentRowCellBorderStyle}">
                                                                <StackPanel Orientation="Horizontal" Width="{StaticResource XSmallItemSize}" HorizontalAlignment="Center" VerticalAlignment="Center" >
                                                                    <CheckBox x:Name="CheckboxAddAnalogs" IsChecked="{Binding Path=AddAnalogs, Mode=TwoWay}" Content="Add"/>
                                                                    <TextBlock Text="[" />
                                                                    <TextBlock Text="{Binding Path=AnalogCount}" />
                                                                    <TextBlock Text="]" />
                                                                </StackPanel>
                                                            </Border>
                                                        </StackPanel>
                                                        <StackPanel Orientation="Horizontal">
                                                            <TextBlock Text="" Width="{StaticResource XXSmallItemSize}" TextAlignment="Center" FontSize="{StaticResource LargeTextSize}" />
                                                            <Border Style="{StaticResource HeaderRowBorderStyle}">
                                                                <TextBlock Text="" Width="{StaticResource XXSmallItemSize}" TextAlignment="Center" FontSize="{StaticResource LargeTextSize}" FontWeight="Bold"/>
                                                            </Border>
                                                            <Border Style="{StaticResource HeaderRowBorderStyle}">
                                                                <TextBlock Text="Label" Width="{StaticResource LargeItemSize}" TextAlignment="Center" FontSize="{StaticResource LargeTextSize}" FontWeight="Bold"/>
                                                            </Border>
                                                            <Border Style="{StaticResource HeaderRowBorderStyle}">
                                                                <TextBlock Text="Type" Width="{StaticResource SmallItemSize}" TextAlignment="Center" FontSize="{StaticResource LargeTextSize}" FontWeight="Bold"/>
                                                            </Border>
                                                            <Border Style="{StaticResource HeaderRowBorderStyle}">
                                                                <TextBlock Text="Phase" Width="{StaticResource SmallItemSize}" TextAlignment="Center" FontSize="{StaticResource LargeTextSize}" FontWeight="Bold"/>
                                                            </Border>
                                                            <Border Style="{StaticResource HeaderRowBorderStyle}">
                                                                <TextBlock Text="Destination" Width="{StaticResource LargeItemSize}" TextAlignment="Center" FontSize="{StaticResource LargeTextSize}" FontWeight="Bold"/>
                                                            </Border>
                                                        </StackPanel>
                                                        <ItemsControl x:Name="ItemControlPhasorList" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding Path=PhasorList}">
                                                            <ItemsControl.ItemTemplate>
                                                                <DataTemplate>
                                                                    <StackPanel Orientation="Horizontal">
                                                                        <StackPanel.Resources>
                                                                            <converter:StringToPhasorTypeConverter x:Key="stringToPhasorTypeConverter" />
                                                                            <converter:StringToPhaseConverter x:Key="stringToPhaseConverter" />
                                                                        </StackPanel.Resources>
                                                                        <TextBlock Text="" Width="{StaticResource XXSmallItemSize}" TextAlignment="Center" FontSize="{StaticResource LargeTextSize}" />
                                                                        <Border Style="{StaticResource ContentRowCellBorderStyle}" Width="{StaticResource XXSmallItemSize}">
                                                                            <CheckBox HorizontalAlignment="Center" IsChecked="{Binding Path=Include, Mode=TwoWay }" />
                                                                        </Border>
                                                                        <Border Style="{StaticResource ContentRowCellBorderStyle}">
                                                                            <TextBox Text="{Binding Path=Label, Mode=TwoWay}" Width="{StaticResource LargeItemSize}" TextAlignment="Left" Height="{StaticResource XXXSmallItemSize}" VerticalAlignment="Center"/>
                                                                        </Border>
                                                                        <Border Style="{StaticResource ContentRowCellBorderStyle}">
                                                                            <ComboBox x:Name="ComboboxType" DisplayMemberPath="Value" SelectedItem="{Binding Path=Type, Mode=TwoWay, Converter={StaticResource stringToPhasorTypeConverter}}" Width="{StaticResource SmallItemSize}" Loaded="ComboboxType_Loaded" Height="{StaticResource XXXSmallItemSize}" VerticalAlignment="Center"/>
                                                                        </Border>
                                                                        <Border Style="{StaticResource ContentRowCellBorderStyle}">
                                                                            <ComboBox x:Name="ComboboxPhase" DisplayMemberPath="Value" SelectedItem="{Binding Path=Phase, Mode=TwoWay, Converter={StaticResource stringToPhaseConverter}}" Width="{StaticResource SmallItemSize}" Loaded="ComboboxPhase_Loaded" Height="{StaticResource XXXSmallItemSize}" VerticalAlignment="Center"/>
                                                                        </Border>
                                                                        <Border Style="{StaticResource ContentRowCellBorderStyle}">
                                                                            <TextBox Text="{Binding Path=Destination, Mode=TwoWay}" Width="{StaticResource LargeItemSize}" TextAlignment="Left" Height="{StaticResource XXXSmallItemSize}" VerticalAlignment="Center"/>
                                                                        </Border>
                                                                    </StackPanel>
                                                                </DataTemplate>
                                                            </ItemsControl.ItemTemplate>
                                                        </ItemsControl>
                                                    </StackPanel>
                                                </DataTemplate>
                                            </ItemsControl.ItemTemplate>
                                        </ItemsControl>
                                    </ScrollViewer>
                                </StackPanel>
                            </layoutToolkit:AccordionItem.Content>
                        </layoutToolkit:AccordionItem>
                    </layoutToolkit:Accordion>
                </Border>
                <Border Style="{StaticResource HeaderRowBorderStyle}">
                    <Grid HorizontalAlignment="Center" Width="{StaticResource ApplicationMinWidth}" Margin="5">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Button x:Name="ButtonPrevious" Grid.Column="0" Content="../../Images/Previous.png" Tag="Previous" Template="{StaticResource ImageButtonTemplate}" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="2" Cursor="Hand">
                            <Button.RenderTransform>
                                <ScaleTransform x:Name="ButtonPreviousTransform" ScaleX="1" ScaleY="1" />
                            </Button.RenderTransform>
                        </Button>
                        <Button x:Name="ButtonNext" Grid.Column="1" Content="../../Images/Next.png" Tag="Next" Template="{StaticResource ImageButtonTemplate}" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="2" Cursor="Hand">
                            <Button.RenderTransform>
                                <ScaleTransform x:Name="ButtonNextTransform" ScaleX="1" ScaleY="1" />
                            </Button.RenderTransform>
                        </Button>
                    </Grid>
                </Border>
            </StackPanel>
        </Border>
    </Grid>
</navigation:Page>